<?php

class Userv2mobile_model extends Base_Model
{
    const TABLE = 'user_v2_mobile_code';

    public function __construct()
    {
        $this->load->database();
    }

    /**
     * 添加验证码
     *
     * @param $data
     * @return bool|int
     */
    public function addSmsCode($data)
    {
        if($this->db->insert(self::TABLE, $data)){
            return $this->db->insert_id();
        }else{
            return false;
        }
    }

    /**
     * 获取验证码
     *
     * @param $where
     * @return array
     */
    public function getSmscode($where)
    {
        $query = $this->db->select('code,created')->order_by('id desc')
                      ->get_where(self::TABLE, $where);

        return $query->row_array();
    }
}